#ifndef PXUTILS_H
#define PXUTILS_H

#include <QString>
#include <QGuiApplication>
#include <QScreen>

class PXUtils
{
public:
    PXUtils();
    static QPair<double, double>  calcCmToPx()
    {
        QScreen *screen = QGuiApplication::primaryScreen();
        if (!screen) return  qMakePair(1.0, 1.0);

        // 获取 DPI
        double dpiX = screen->physicalDotsPerInchX();
        double dpiY = screen->physicalDotsPerInchY();

        // 计算每厘米对应的像素数
        double pxPerCmX = dpiX / 2.54;
        double pxPerCmY = dpiY / 2.54;

        qDebug() << "屏幕 DPI: X =" << dpiX << ", Y =" << dpiY;
        qDebug() << "1 cm = " << pxPerCmX << " px (X方向)";
        qDebug() << "1 cm = " << pxPerCmY << " px (Y方向)";
        return qMakePair(pxPerCmX, pxPerCmY);
    }
};

#endif // PXUTILS_H
